﻿using System.Collections.Generic;
using System.IO;

namespace VSCoverageToEmma
{
	public static class ConverterHelper
	{
		public static IEnumerable<string> TraverseFiles(string folderPath, string searchPattern)
		{
			// SearchOption.AllDirectories not use, because results are array, cannot continuous iteration.
			foreach (var filePath in Directory.GetFiles(folderPath, searchPattern, SearchOption.TopDirectoryOnly))
			{
				yield return filePath;
			}

			foreach (var childFolderPath in Directory.GetDirectories(folderPath))
			{
				foreach (var filePath in TraverseFiles(childFolderPath, searchPattern))
				{
					yield return filePath;
				}
			}
		}
	}
}
